package com.bd08.flink.demo.zhang

import com.bd08.flink.demo.zhang.ReduceDemo.env
import org.apache.flink.api.scala.{ExecutionEnvironment, createTypeInformation}

object ReduceGroup extends App {
  val env = ExecutionEnvironment.getExecutionEnvironment
  val ds  = env.fromCollection(List("a","b","c","d","a","b"))
  ds.reduceGroup(elements => elements.toList.toString()).print()
  ds.map((_,1)).groupBy(0).reduceGroup(elements =>
    elements.reduce((x,y)=>(x._1,x._2+y._2))).print()

}
